﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Management;
using System.Runtime.InteropServices;
using System.Threading;

namespace GetIP2PCName
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void getlist_btn_Click(object sender, EventArgs e)
        {
            // 
            string IpPrefix = "172.28.3";
            int stIP = int.Parse(startIp_ed.Text);
            int edIP = int.Parse(endIp_ed.Text);
            ComputerAddressInfo cai = new ComputerAddressInfo(IpPrefix, stIP, edIP);
            //Thread thScan = new Thread(new ThreadStart(cai.ScanComputers));
            //thScan.Start();
            cai.ScanComputers();

            //MessageBox.Show(cai.ComputerList.Count.ToString());

            dataGridView1.RowCount = 0;
            for (int i = 0; i < cai.ComputerList.Count; i++)
            {
                string[] arr = new string[2];
                arr = (string[])cai.ComputerList[i];
                dataGridView1.Rows.Add(arr[1], arr[0]);
            }
        }
    }
}
